<!DOCTYPE html >
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>success</title>
    <link rel="shortcut icon" th:href="@{/favicon.ico}">

    <script type="text/javascript">
        function logoutFunc(){
            document.getElementById('logoutBtn').click();
        }
    </script>
</head>

<body>
    <h1>登录成功</h1>
    <a href="https://github.com/thymeleaf/thymeleaf-extras-springsecurity" target="_blank">thymeleaf-extras-springsecurity 官方api</a>
    </br>
    <div sec:authorize="hasRole('ROLE_ADMIN')">
        拥有 ROLE_ADMIN 角色
    </div>
    </br>
    当前登录人: <span sec:authentication="name">xxx</span></br>
    拥有角色: <span sec:authentication="principal.authorities">xxx</span>

    <ul>
        <li > <a th:href="@{/test/product/456}">产品</a></li>
        <li > <a th:href="@{/test/order/123}">订单</a></li>
        <li>
            <!-- 如果开启了csrf，logout 必须使用post方法-->
            <form th:action="@{/logout}" method="POST" style="display: none">
                <input type="submit" value="Logout" id="logoutBtn" />
            </form>

            <a href="javascript:void(0);" onclick="logoutFunc()">注销登录</a></li>
    </ul>


</body>
</html>